<?php 

function getTree($list,$pid='0',$level='0',$html="&nbsp;&nbsp;&nbsp;"){
	$arr=array();
	foreach ($list as $key=>$v)
	{
		if($v['pid']==$pid)
		{
			$v['html']=str_repeat($html,$level);
			$v['levels']=$level+1;
			$arr[] = $v;
			$arr=array_merge($arr,getTree($list,$v['id'],$level+1));

		}
	}
	return $arr;
}


 ?>